// 文章相关的操作
import request from '@/utils/request'
import { ReqArticleList } from '@/types/article'

// 获取文章列表，需要传入频道id和时间戳
export const reqGetArticles = (channel_id: string, timestamp: number) => request.get<ReqArticleList>('/v1_0/articles', {
  params: {
    with_top: 1,
    channel_id,
    timestamp
  }
})
// 不喜欢的文章接口,传入对应文章的id
export const reqDislikeArticle = (target: string) => request.post('/v1_0/article/dislikes', { target })
// 举报文章，传入对应的id
export const reqReportArticle = (target: string, type: string) => request.post('/v1_0/article/reports', { target, type })
// 文章详情
export const reqGetArticleInfo = (id: string) => request.get(`/v1_0/articles/${id}`)
// 点赞文章
export const reqSetLike = (target: string) => request.post('/v1_0/article/likings', { target })
// 取消点赞文章
export const reqDelLike = (target: string) => request.delete(`/v1_0/article/likings/${target}`)
// 不喜欢的
export const reqDislike = (target: string) => request.post('/v1_0/article/dislikes', { target })
// 取消不喜欢
export const reqCancelDislike = (target: string) => request.delete(`/v1_0/article/dislikes/${target}`)
// 获取文章评论
export const reqGetComments = (type: string, source: string, offset: string = '1', limit: number = 10) => request.get('/v1_0/comments', { params: { type, source, offset, limit } })
// 对评论或者回复进行点赞
export const reqSetGood = (target: string) => request.post('/v1_0/comment/likings', { target })
// 对文章进行评论
export const reqSetComment = (target: string, content: string, id?: string) => request.post('/v1_0/comments', { target, content, art_id: id })
// 取消对文章的点赞
export const reqDelGood = (target: string) => request.delete(`/v1_0/comment/likings/${target}`)
